package com.offcn.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.offcn.pojo.Setmeal;
import com.offcn.service.SetmealService;
import com.offcn.utils.MessageConstant;
import com.offcn.utils.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: wy
 * @Date: 2022/9/1 20:01
 */
@RestController
@RequestMapping("setmealcli")
public class SetmealController {

    private Result result;

    @Reference
    private SetmealService setmealService;

    //offcnpe_mobile 的查询
    @RequestMapping("getAllSetmeal")
    public Result getAllSetmeal() {
        try {
            List<Setmeal> list = setmealService.getAllSetmeal();
            result = new Result(true, "", list);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return result;
    }

    // offcnpe_mobile 通过id进行查询
    @RequestMapping("findInfoById")
    public Result findInfoById(Integer id) {
        try {
            Setmeal setmeal = setmealService.findInfoById(id);
            result = new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, setmeal);
        } catch (Exception e) {
            result = new Result(true, MessageConstant.QUERY_SETMEAL_FAIL, null);
        }
        return result;
    }
}
